package DataStructures.mySort;

import org.junit.Test;

import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

/**
 * @Author: yqy
 * @Date: 2022/06/07/21:43
 * @Description:
 */
public class Run {
    public static void main(String[] args) {
        System.out.println("请输入数组长度：");
        Scanner sc=new Scanner(System.in);
        int len = sc.nextInt();
        bubbleTest(len);
        System.out.println("\n\n");
        selectTest(len);
        System.out.println("\n\n");
        insertTest(len);
    }
    //冒泡排序测试
    private static void insertTest(int len){
        int[] arrayInsert=new int[len];
        for (int i = 0; i < len; i++) {
            arrayInsert[i]=new Random().nextInt(len);
        }
        System.out.println("原数组"+Arrays.toString(arrayInsert));


        long start = System.currentTimeMillis();
        int[] insert=Insert.insert(arrayInsert);
        long end = System.currentTimeMillis();
        System.out.println("排序时长："+(end-start));
        System.out.println("排序后数组"+Arrays.toString(insert));
    }

    //冒泡排序测试
    private static void selectTest(int len){
        int[] arraySelect=new int[len];
        for (int i = 0; i < len; i++) {
            arraySelect[i]=new Random().nextInt(len);
        }
    //    System.out.println("原数组"+Arrays.toString(arraySelect));


        long start = System.currentTimeMillis();
        int[] select = Select.select(arraySelect);
        long end = System.currentTimeMillis();
        System.out.println("排序时长："+(end-start));
      //  System.out.println("排序后数组"+Arrays.toString(select));
    }

    //冒泡排序测试
    private static void bubbleTest(int len){
        int[] arrayBubble=new int[len];
        for (int i = 0; i < len; i++) {
            arrayBubble[i]=new Random().nextInt(len);
        }
      //  System.out.println("原数组"+Arrays.toString(arrayBubble));


        long start = System.currentTimeMillis();
        int[] bubble = Bubble.bubble(arrayBubble);
        long end = System.currentTimeMillis();
        System.out.println("排序时长："+(end-start));
      //  System.out.println("排序后数组"+Arrays.toString(bubble));
    }
}
